package day3;

/**
 * ClassName：Test1
 *
 * @Author：小鱼
 * @Create：2025-08-20 9:20
 */
public class Test1 {
    public static void main(String[] args) {
        Thread th1 = new Thread(){
            @Override
            public void run(){
                for (int i = 1; i < 40; i++) {
                    System.out.println("th1: "+i);
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };

        Thread th2 = new Thread(
                new Runnable() {
                    @Override
                    public void run() {
                        for (int i = 100; i >=70; i--) {
                            System.out.println("th2: "+i);
                            try {
                                Thread.sleep(10);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                            if(i==80){
                                System.out.println("th1"+th1.getState());
                               // System.out.println("th2"+th2.getState());
                                try {
                                    th1.join();
                                    System.out.println("th1"+th1.getState());
                                    //System.out.println("th1"+th2.getState());
                                } catch (InterruptedException e) {
                                    e.printStackTrace();
                                }
                            }
                        }
                    }
                }
        );
        th1.start();
        th2.start();
    }
}
